﻿using System.IO;
using NthDownload.Common.ViewModels;

namespace NthDownload.DownloadPlugins.Http.ViewModels
{
    public class HttpGeneralSettingsViewModel : ViewModelScreenBase
    {
        #region Class Members

        private HttpSettings _HttpSettings;

        #endregion Class Members

        #region Constructors

        public HttpGeneralSettingsViewModel(HttpSettings settings)
        {
            Settings = settings;
        }

        #endregion Constructors

        #region Properties

        /// <summary>
        /// Settings
        /// </summary>
        public HttpSettings Settings 
        {
            get
            {
                return _HttpSettings;
            }
            private set
            {
                _HttpSettings = value;
                NotifyOfPropertyChange(() => Settings);
            }
        }

        #endregion Properties

        #region Methods

        /// <summary>
        /// Changes the default destination path
        /// </summary>
        public void ChangeDefaultDestination()
        {
            System.Windows.Forms.FolderBrowserDialog dlgDest = new System.Windows.Forms.FolderBrowserDialog();
            if (dlgDest.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            DirectoryInfo diDest = new DirectoryInfo(dlgDest.SelectedPath);

            if (!diDest.Exists)
            {
                return;
            }

            Settings.DefaultDestinationPath = diDest.FullName;
        }

        #endregion Methods
    }
}
